const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
/**
 * @type {import('webpack').Configuration}
 */

module.exports = {
  mode: 'none',
  stats: 'none',
  devtool: 'eval-cheap-module-source-map',
  entry: './src/main-hmr.js',
  output: {
    path: path.join(__dirname, 'dist-hmr'),
    filename: 'js/bundle.js',
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env'],
          },
        },
      },
      {
        test: /\.css$/,
        use: ['style-loader', 'css-loader'],
      },
      {
        test: /\.(png|jpg)/,
        use: {
          loader: 'url-loader',
          options: {
            limit: 1024 * 10,
          },
        },
      },
    ],
  },
  devServer: {
    port: 3002,
    hot: true,
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new HtmlWebpackPlugin({
      template: 'index-hmr.html',
    }),
  ],
};
